

Page({
  data: {

    // addrArray: util.replacePhone(mydata.userData().addrs, true),
    addrIndex: 0,
    date: '2020-1-12',
    time: '12:00',
    date1: '2019-1-12',
    time1: '12:00',
    bookToastHidden: true,
  },
  // 借阅图书开始日期选择
  bindDateChange: function (e) {
    console.log('date picker发送选择改变，携带值为', e.detail.value)
    wx.setStorageSync("begtime", e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  // 借阅图书开始时间选择
  bindTimeChange: function (e) {
    //app.globalData.date1 = e.detail.value
    console.log('time picker发送选择改变，携带值为', e.detail.value)
    wx.setStorageSync("begtime1", e.detail.value)
    this.setData({
      time: e.detail.value
    })
  },

  // 借阅图书结束日期选择
  bindDateChange1: function (e) {
    console.log('date picker发送选择改变，携带值为', e.detail.value)
    wx.setStorageSync("begtime2", e.detail.value)
    this.setData({
      date1: e.detail.value
    })

  },
  //借阅图书结束 时间选择
  bindTimeChange1: function (e) {
    //app.globalData.date1 = e.detail.value
    console.log('time picker发送选择改变，携带值为', e.detail.value)
    wx.setStorageSync("begtime3", e.detail.value)
    this.setData({
      time1: e.detail.value
    })
  },
  //获取输入的图书名称
  aquery: function (e) {
    var borbookname = e.detail.value
    wx.setStorageSync("borbookname", borbookname)
  },
    //获取输入的借阅的数量
  aquery1: function (e) {
    var bornum = e.detail.value
    wx.setStorageSync("bornum", bornum)
  },
  
  //图书借阅
  apply: function () {
    var borname = wx.getStorageSync("uname")
    if (!borname){
      wx.showModal({
        title: '提示',
        content: '请登录',
      })
    }else{
      var borbookname = wx.getStorageSync("borbookname")
      var bornum ="1"
      var bdamage = "0"
      var btag = "1"
      var borname = wx.getStorageSync("uname")
      var begtime = wx.getStorageSync("begtime")
      var begtime1 = wx.getStorageSync("begtime1")
      var begtime2 = wx.getStorageSync("begtime2")
      var begtime3 = wx.getStorageSync("begtime3")
      var borbegintime = begtime + " " + begtime1//借图书开始时间
      var borendtime = begtime2 + " " + begtime3//借图书结束时间
      console.log(borbookname, bornum,borname,borbegintime,borendtime)
      wx.request({
        url: 'http://localhost:8080/parking/bookhis/addbookhis',
        data: {
          borname: borname,
          borbookname: borbookname,
          bornum: bornum,
          borbegintime: borbegintime,
          borendtime: borendtime,
          bdamage:bdamage,
          btag:btag
        },
        success: function (res) {
          var mess = res.data.mess
          if (mess === "成功") {
            wx.showModal({
              title: '提示',
              content: '借阅成功',
            })
          } else {
            wx.showModal({
              title: '提示',
              content: '借阅失败',
            })
          }
        }
      })
    }


  }






})